﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Validation Application Block
//===============================================================================
// Code file original author: Martin Lapierre, http://devinstinct.com
//===============================================================================

using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace EntLibContrib.Validation.Validators
{
	/// <summary>
	/// Provides pre-allocated, thread-safe validators that are type-dependent.
	/// </summary>
	/// <typeparam name="T">The target type.</typeparam>
	public class StronglyTypedValidators<T>
	{
		#region Fields
		/// <summary>
		/// Validates that objects references are not null and that the objects are of the type-parameter type, using the default ruleSet.
		/// </summary>
		private AndCompositeValidator notNullTypeValidator = new AndCompositeValidator(DefaultValidators.NotNullValidator, new TypeValidator<T>());

		/// <summary>
		/// Validates that objects references are not null and that the objects are valid by themselves, using the default ruleSet.
		/// </summary>
		private AndCompositeValidator notNullObjectValidator = new AndCompositeValidator(DefaultValidators.NotNullValidator, new ObjectValidator<T>());
		#endregion

		#region Properties
		/// <summary>
		/// Validates that objects references are not null and that the objects are of the type-parameter type, using the default ruleSet.
		/// </summary>
		public AndCompositeValidator NotNullTypeValidator
		{
			get { return notNullTypeValidator; }
		}

		/// <summary>
		/// Validates that objects references are not null and that the objects are valid by themselves, using the default ruleSet.
		/// </summary>
		public AndCompositeValidator NotNullObjectValidator
		{
			get { return notNullObjectValidator; }
		}
		#endregion
	}
}
